package com.jiazhong.Dao.Impl;

import com.jiazhong.Dao.DBUtils;
import com.jiazhong.Dao.UserDao;
import com.jiazhong.Model.User;

public class UserDaoImpl extends DBUtils implements UserDao {
    @Override
    public User loadUserByUsername(String username) {
        String sql = "select * from tbl_user where user_name=?";
        return super.executeQueryOne(User.class,sql,username);

    }

    @Override
    public User login(String username, String password) {
        String sql = "select * from tbl_user where user_name=? and user_password=?";
        return super.executeQueryOne(User.class,sql,username,password);
    }

    @Override
    public void addUser(User user) {
        String sql = "insert into tbl_user values(default,?,?)";
        super.executeUpdate(sql,user.getUser_name(),user.getUser_password());
    }
}
